<?php
class MGameTags extends MY_Model {
	public $table = 'game_tags';
	private $filter = array();
	function __construct() {
		parent::__construct();
	}
	public function deleteGameId($gameId){
		$this->db->where('game_id', $gameId);
		$ret = $this->db->delete($this->table);
		if($ret && $this->db->affected_rows() >= 1){
			return true;
		}
		return false;
	}
	public function delete($id, $update_time){
		$this->db->where('id', $id);
		$this->db->where('update_time', $update_time);
		$ret = $this->db->delete($this->table);
		if($ret || $this->db->affected_rows() >= 1){
			return true;
		}
		return false;
	}
	
	public function deleteTagsOfGameId($gameId){
		$this->db->where('game_id', $gameId);
		$ret = $this->db->delete($this->table);
		if($ret || $this->db->affected_rows() >= 1){
			return true;
		}
		return false;
	}
	
	public function getAllSelectedTags($gameId){
		$this->db->select('tag_id');
		$this->db->from($this->table);
		$this->db->where('game_id',$gameId);
		$result = $this->db->get()->result();
		$selectedTagsArr = Array();
		foreach ($result as $item){
			$selectedTagsArr[] = $item->tag_id;
		}
		return $selectedTagsArr;
	}
	
	public function getListBySiteId($site_id){
		$this->db->select('*');
		$this->db->from($this->table);
		$this->db->where('site_id', $site_id);
		$this->db->order_by('disp_sort', 'asc');
		return $this->db->get()->result();
	}
}
